<template>
  <div>
    {{ time }}
  </div>
</template>

<script>
import moment from "moment";

export default {
  name: "Timer",
  data() {
    return {
      time: moment().format("YYYY-MM-DD HH:mm:ss"),
      timerNo: null,
    };
  },
  created() {
    this.timerNo = setInterval(() => {
      this.time = moment().format("YYYY-MM-DD HH:mm:ss");
    }, 1000);
  },
  beforeDestroy() {
    if (this.timerNo) {
      clearInterval(this.timerNo);
    }
  },
};
</script>

<style>
</style>